package com.newx.file.enums;

import lombok.Getter;

/**
 * @Classname OpenApiEnum
 * @Description TODO
 * @Date 2023/12/7 11:40
 * @Created by yxl
 */
@Getter
public enum FileApiEnum {

    LOCAL("LOCAL","localFileApiTemplateImpl","本地上传"),
    ALIYUN("ALIYUN","aliyunFileApiTemplateImpl","阿里云上传"),
    TENCENT("TENCENT","tencentFileApiTemplateImpl","腾讯云上传"),;

    /**
     * 存储引擎
     */
    private final String engine;

    /**
     * 处理器名称
     */
    private final String beanName;

    /**
     * 描述
     */
    private final String desc;

    FileApiEnum(String engine, String beanName, String desc) {
        this.engine = engine;
        this.beanName = beanName;
        this.desc = desc;
    }

    /**
     * 根据gateway获取beanName
     * @param engine 存储引擎
     * @return 处理器名称
     */
    public static String getBeanNameByGateway(String engine) {
        for (FileApiEnum value : FileApiEnum.values()) {
            if (value.getEngine().equals(engine)) {
                return value.getBeanName();
            }
        }
        return null;
    }

    /**
     * 校验gateway是否合法
     * @param engine 存储引擎
     * @return 是否合法
     */
    public static Boolean checkGateway(String engine) {
        for (FileApiEnum value : FileApiEnum.values()) {
            if (value.getEngine().equals(engine)) {
                return true;
            }
        }
        return false;
    }
}
